package priv.yiyuan.example.composite.approvar1;

/**
 * 员工
 * <p>
 * 组合模式-叶子节点
 *
 * @author YiYuan
 * @data 2025/8/29
 * @apoNote
 */
public class Employee implements Approver {

    private String name;

    private String title;

    private double maxApprovalLimit;

    public Employee(String name, String title, double maxApprovalLimit) {
        this.name = name;
        this.title = title;
        this.maxApprovalLimit = maxApprovalLimit;
    }

    @Override
    public void processRequest(ApprovalRequest request) {

        System.out.println("员工 " + name + " (" + title + ") 正在处理请求: " + request);
        if (request.getAmount() <= maxApprovalLimit) {
            System.out.println("  " + name + " 批准了请求。");
        }
        else {
            System.out.println("  " + name + " 无法处理此请求(超出限额: " + maxApprovalLimit + ")。");
        }

    }

    @Override
    public void add(Approver approver) {
        System.out.println("员工不能添加子审批者。");
    }

    @Override
    public void remove(Approver approver) {
        System.out.println("员工不能移除子审批者。");
    }

    @Override
    public double getApprovalLimit() {
        return this.maxApprovalLimit;
    }

    public String getName() {
        return name;
    }

}
